package com.sxjh.controller.cb;

import com.sxjh.common.BaseController;
import com.sxjh.config.Authorization;
import com.sxjh.common.Result;
import com.sxjh.entity.param.Finance2Param;
import com.sxjh.entity.param.Finance4ListParam;
import com.sxjh.entity.param.MethylAlcoholListParam;
import com.sxjh.entity.result.Finance4KhMxResult;
import com.sxjh.entity.result.MethylAlcoholListResult;
import com.sxjh.service.FinanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "化品回收厂")
@RestController
@RequestMapping("/chemical-sell")
public class Finance2Controller extends BaseController {

  @Autowired
  private FinanceService financeService;

  @ApiOperation("肥料级硫酸铵")
  @GetMapping("/lsa")
  @Authorization("cb.chemical-sell.lsa")
  Result<List<MethylAlcoholListResult>> list(@Validated Finance2Param param) {
    MethylAlcoholListParam param1 = new MethylAlcoholListParam();
    param1.setStartDate(param.getStartDate());
    param1.setEndDate(param.getEndDate());
    param1.setMaterialId(38);
    List<MethylAlcoholListResult> list = financeService.list3(param1);
    return ok(list);
  }

  @ApiOperation("工业硫磺")
  @GetMapping("/lh")
  @Authorization("cb.chemical-sell.lh")
  Result<List<MethylAlcoholListResult>> list2(@Validated Finance2Param param) {
    MethylAlcoholListParam param1 = new MethylAlcoholListParam();
    param1.setStartDate(param.getStartDate());
    param1.setEndDate(param.getEndDate());
    param1.setMaterialId(39);
    List<MethylAlcoholListResult> list = financeService.list3(param1);
    return ok(list);
  }

  @ApiOperation("硫膏")
  @GetMapping("/lg")
  @Authorization("cb.chemical-sell.lg")
  Result<List<MethylAlcoholListResult>> list3(@Validated Finance2Param param) {
    MethylAlcoholListParam param1 = new MethylAlcoholListParam();
    param1.setStartDate(param.getStartDate());
    param1.setEndDate(param.getEndDate());
    param1.setMaterialId(42);
    List<MethylAlcoholListResult> list = financeService.list3(param1);
    return ok(list);
  }

  @ApiOperation("熔融硫")
  @GetMapping("/rrl")
  @Authorization("cb.chemical-sell.rrl")
  Result<List<MethylAlcoholListResult>> list4(@Validated Finance2Param param) {
    MethylAlcoholListParam param1 = new MethylAlcoholListParam();
    param1.setStartDate(param.getStartDate());
    param1.setEndDate(param.getEndDate());
    param1.setMaterialId(40);
    List<MethylAlcoholListResult> list = financeService.list3(param1);
    return ok(list);
  }

  @ApiOperation("化产脱硫副盐")
  @GetMapping("/fy")
  @Authorization("cb.chemical-sell.fy")
  Result<List<MethylAlcoholListResult>> list5(@Validated Finance2Param param) {
    MethylAlcoholListParam param1 = new MethylAlcoholListParam();
    param1.setStartDate(param.getStartDate());
    param1.setEndDate(param.getEndDate());
    param1.setMaterialId(41);
    List<MethylAlcoholListResult> list = financeService.list3(param1);
    return ok(list);
  }
  @ApiOperation("化工回收厂客户分类开票报表")
  @GetMapping("/KhFlKp")
//  @Authorization("cb.chemical-sell.fy")
  Result<List<Finance4KhMxResult>> list28(@Validated Finance4ListParam param) {
    param.setCategoryId(7);
    List<Finance4KhMxResult> list = financeService.list33(param,1);
    return ok(list);
  }

  @ApiOperation("化工回收厂客户销售报表")
  @GetMapping("/KhXs")
//  @Authorization("cb.chemical-sell.fy")
  Result<List<Finance4KhMxResult>> list29(@Validated Finance4ListParam param) {
    param.setCategoryId(7);
    List<Finance4KhMxResult> list = financeService.list33(param,2);
    return ok(list);
  }

}
